package com.bridgetree.jubaocrm.ui.project;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bridgetree.jubaocrm.R;
import com.bridgetree.jubaocrm.util.Contact;

/**
 *客户联系人详情
 */
public class XMChildCustomerContactItemActivity extends Activity {
	private final String TAG ="XMChildCustomerContactActivity";
	private ArrayList<String> proInfoListData = null;
	private Contact mContact ;
	
	private TextView xm_ccd_tv_name=null;
	private TextView xm_ccd_tv_tel=null;
	private TextView xm_ccd_tv_zj=null;
	private TextView xm_ccd_tv_weixin=null;
	private TextView xm_ccd_tv_qq=null;
	private TextView xm_ccd_tv_msn=null;
	private TextView xm_ccd_tv_mail=null;
	private TextView xm_ccd_tv_work=null;
	private TextView xm_ccd_tv_beizhu=null;

	private RelativeLayout callphone;
	private RelativeLayout callphonezj;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.xm_customer_contact_details);

		Intent intent = getIntent();
		if (intent == null) {
			Log.e(TAG, "intent is null");
			return;
		}
		
		callphone=(RelativeLayout)findViewById(R.id.callphone);
		callphonezj=(RelativeLayout)findViewById(R.id.callphonezj);
		xm_ccd_tv_tel=(TextView)findViewById(R.id.xm_ccd_tv_tel);

		TextView xm_bi_tv_title =(TextView)findViewById(R.id.xm_bi_tv_title);
		xm_ccd_tv_name =(TextView)findViewById(R.id.xm_ccd_tv_name);
		xm_ccd_tv_zj =(TextView)findViewById(R.id.xm_ccd_tv_zj);
		xm_ccd_tv_weixin =(TextView)findViewById(R.id.xm_ccd_tv_weixin);
		xm_ccd_tv_qq =(TextView)findViewById(R.id.xm_ccd_tv_qq);
		xm_ccd_tv_msn =(TextView)findViewById(R.id.xm_ccd_tv_msn);
		xm_ccd_tv_mail =(TextView)findViewById(R.id.xm_ccd_tv_mail);
		xm_ccd_tv_work =(TextView)findViewById(R.id.xm_ccd_tv_work);
		xm_ccd_tv_beizhu =(TextView)findViewById(R.id.xm_ccd_tv_beizhu);
		
		if(intent.getExtras()!=null){
			mContact = (Contact)intent.getExtras().getSerializable("Contact");
			xm_bi_tv_title.setText("资料（"+mContact.getFullname()+"）");
			xm_ccd_tv_name.setText(mContact.getFullname());
			xm_ccd_tv_tel.setTextColor(Color.BLUE);
			xm_ccd_tv_tel.setText(Html.fromHtml("<u>"+mContact.getCellphone()+"</u>"));
			xm_ccd_tv_zj.setTextColor(Color.BLUE);
			xm_ccd_tv_zj.setText(Html.fromHtml("<u>"+mContact.getFixed_phone()+"</u>"));
			xm_ccd_tv_weixin.setText(mContact.getWeixin());
			xm_ccd_tv_qq.setText(mContact.getQq());
			xm_ccd_tv_msn.setText(mContact.getMsn());
			xm_ccd_tv_mail.setText(mContact.getEmail());
			xm_ccd_tv_work.setText(mContact.getJob());
			xm_ccd_tv_beizhu.setText(mContact.getCommit());
		}

		findViewById(R.id.xm_cci_RelativeLayout_back).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		callphone.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String number =xm_ccd_tv_tel.getText().toString();
				if(!number.equals("")){
					try {
						Intent phoneIntent = new Intent("android.intent.action.CALL",Uri.parse("tel:" + number));   
						startActivity(phoneIntent);
					} catch (Exception e) {
						e.printStackTrace();
					}   
				}
			}
		});
		callphonezj.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String number =xm_ccd_tv_zj.getText().toString();
				if(!number.equals("")){
					try {
						Intent phoneIntent = new Intent("android.intent.action.CALL",Uri.parse("tel:" + number));   
						startActivity(phoneIntent);
					} catch (Exception e) {
						e.printStackTrace();
					}   
				}
			}
		});
		
		
	}

}
